import qrcodeTerminal from 'qrcode-terminal';
import { qwPicMsg, qwMsg } from './qw_msg.ts';

export function onScan(qrcode, code) {
	console.log('qrcode', qrcode);
	console.log('code', code);
	qrcodeTerminal.generate(qrcode, { small: true }); // 在console端显示二维码
	const qrcodeImageUrl = [
		'https://api.qrserver.com/v1/create-qr-code/?data=',
		encodeURIComponent(qrcode),
	].join('');
	console.log('qrcodeImageUrl', qrcodeImageUrl);

	qwMsg('扫描以下二维码登录微信机器人');
	qwPicMsg(qrcodeImageUrl);
}
